using VixCOM;

namespace Weever.VmWare
{
    public class VM
    {
        private readonly IVM _vm;

        public VM(IVM vm)
        {
            _vm = vm;
        }

        public void PowerOn(PowerOnOptions options)
        {
            Library.WaitWithoutResults(_vm.PowerOn((int)options, null, null));
        }

        public void PowerOn()
        {
            PowerOn(PowerOnOptions.LaunchGui);
        }

        public void LoginInGuest(string userName, string userPassword)
        {
            Library.WaitWithoutResults(_vm.LoginInGuest(userName, userPassword, 0, null));
        }

        public void LogoutFromGuest()
        {
            Library.WaitWithoutResults(_vm.LogoutFromGuest(null));
        }

        public void PowerOff()
        {
            Library.WaitWithoutResults(_vm.PowerOff(Constants.VIX_VMPOWEROP_NORMAL, null));
        }

        public void Suspend()
        {
            Library.WaitWithoutResults(_vm.Suspend(Constants.VIX_VMPOWEROP_NORMAL, null));
        }

        public void WaitForVMTools()
        {
            Library.WaitWithoutResults(_vm.WaitForToolsInGuest(0, null));
        }
    }
}
